﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Collections.ObjectModel;
using System.Data.SqlClient;
using Microsoft.SharePoint.Portal.Analytics.UI;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace SharePoint.Extensions.MOSSAnalytics
{
    public class GetTopQueries : QueryTopLargeListReportControl
    {
        private int _numberofresults = 100;

        public int NumberOfResults
        {
            get 
            {
                return _numberofresults;   
            }
            set
            {
                _numberofresults = value;
            }
        }
        protected override string RdlFileName
        {
            get { throw new NotImplementedException(); }
        }

        protected override string StoredProcedureName
        {
            get 
            {
                return "proc_MSS_QLog_TopQueries";
            }
        }

        public DataTable GetData()
        {
            return this.LoadReportData();
        }

        protected override string TitleText
        {
            get {return "GetTopQueriesControl";}
        }

        protected override Collection<SqlParameter> StoredProcedureParameters
        {
            get
            {
                Collection<SqlParameter> storedProcedureParameters = new Collection<SqlParameter>();
                Guid guid = SPControl.GetContextSite(this.Context).ID;
                storedProcedureParameters.Add(new SqlParameter("@siteGuid", guid));
                storedProcedureParameters.Add(new SqlParameter("@isSspLevel", this.IsSspLevel));
                storedProcedureParameters.Add(new SqlParameter("@topResultsCount", this.TopResultsCount));
                return storedProcedureParameters;
            }
        }

    }
}
